#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void swapRows(char name[][8], int row1, int row2,int cols)
{
    char tmp[8];
    for (int i = 0; i < cols; i++)
    {
        tmp[i] = name[row1][i];
        name[row1][i] = name[row2][i];
        name[row2][i] = tmp[i];
    }
}
int main()
{
    int n = 0;
    scanf("%d", &n);
    char name[100][8] = { 0 };
    int num[100] = { 0 };
    int sum = 0;
    int i = 0;
    while (i < n)
    {
        scanf("%s %d", name[i],&num[i]);
        //scanf("%d", &num[i]);
        sum += num[i];
        i++;
    }
    int average = sum / n / 2;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < n - 1 - i; j++)
        {
            if (num[i] > num[i + 1])
            {
                int tmp1 = num[i + 1];
                num[i + 1] = num[i];
                num[i] = tmp1;
                swapRows(name, i, i + 1,8);
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (i == 0 && num[i] >= average)
        {
            printf("%d %s", average, name[i]);
            break;
        }
        if (num[i] < average)
        {
            ;
        }
        if (num[i] > average)
        {
            if (average - num[i - 1] > num[i] - average)
            {
                printf("%d %s", average, name[i]);
                break;
            }
            else
            {
                printf("%d %s", average, name[i - 1]);
                break;
            }
        }
    }
    return 0;
}